<template>
  <div class="container">
    <div class="header">
      <h3 class="title">派单</h3>
    </div>
    
    <div class="list">
      <div v-for="(item, index) in staffList" :key="index" class="list-item" @click="showPopup(item)">
        <img :src="item.avatar" alt="头像" class="avatar"/>
        <div class="item-info">
          <span class="name">{{ item.name }}</span>
          <span class="status">{{ item.status }}</span>
        </div>
      </div>
    </div>

    <!-- 圆角弹窗（居中） -->
    <van-popup v-model:show="showCenter" round :style="{ padding: '20px', width: '80%' }">
      <div class="popup-content">
        <h4 class="popup-title">确认派单</h4>
        <div class="staff-info">
          <img :src="selectedStaff?.avatar" alt="头像" class="popup-avatar"/>
          <div class="info-detail">
            <p class="staff-name">{{ selectedStaff?.name }}</p>
            <p class="staff-status">{{ selectedStaff?.status }}</p>
          </div>
        </div>
        <van-button type="primary" block round @click="confirmDispatch">确认派单</van-button>
      </div>
    </van-popup>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const showCenter = ref(false)
const staffList = ref([
  {
    id: 1,
    avatar: 'src/assets/avatar.jpg',
    name: '小哥一号',
    status: '空闲'
  },
  {
    id: 2,
    avatar: 'src/assets/avatar.jpg',
    name: '小哥二号',
    status: '接单中'
  }
])

const selectedStaff = ref(null)

const showPopup = (item) => {
  selectedStaff.value = item
  showCenter.value = true
}

const confirmDispatch = () => {
  // TODO: 实现派单逻辑
  showCenter.value = false
}
</script>

<style scoped>
.container {
  background: linear-gradient(180deg, rgba(195, 207, 226, 1) 0%, rgba(245, 247, 250, 1) 100%);
  min-height: 100vh;
}

.header {
  background-color: #4050B5;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.title {
  flex-grow: 1;
  color: #fff;
  text-align: center;
  font-size: 18px;
  margin: 0;
  letter-spacing: 10px;
}

.list {
  margin: 10px 10px;
}

.list-item {
  background-color: #fff;
  margin: 20px 0;
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-right: 15px;
}

.item-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.name {
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.status {
  font-size: 18px;
  font-weight: bold;
  color: #666;
}

.popup-content {
  text-align: center;
}

.popup-title {
  margin: 0 0 20px;
  font-size: 18px;
  color: #333;
}

.staff-info {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px;
  background: #f8f8f8;
  border-radius: 10px;
}

.popup-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-right: 15px;
}

.info-detail {
  text-align: left;
}

.staff-name {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.staff-status {
  margin: 5px 0 0;
  font-size: 14px;
  color: #666;
}
</style>